package com.acme.domain.bank;

public abstract class AbstractAccount implements Account{

	private double balance;
	
	public AbstractAccount(){
		this.balance = 50;
	}
	
	@Override
	public double getBalance() {
		return this.balance;
	}
	
	public void setBalance(double balance) {
		this.balance = balance;
	}

	@Override
	public void deposit(double sum) {
		this.balance += sum;
	}

	@Override
	public void withdraw(double sum) throws OverDraftLimitExceededException, NotEnoughFundsException {
		if(this.balance >= sum)
			this.balance -= sum;
		else
			throw new NotEnoughFundsException();
	}

	@Override
	public double decimalValue() {
		return Math.round(balance);
	}

	@Override
	public String toString() {
		return "balance = " + balance;
	}

}
